<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Model_Entity {

  protected $_data;

  public function __construct($data = NULL) {
    $this->_data = (array) $data;
  }

  public function model() {
    return str_replace('_Entity_', '_', get_class($this));
  }

  public function refresh() {
    $this->_data = Model::refresh($this);
  }

  public function save() {
    return Model::save($this);
  }

  public function __get($name) {
    return @$this->_data[$name];
  }

  public function __set($name, $value) {
    $this->_data[$name] = $value;
  }

  public function offsetExists($offset) {
    return isset($this->_data[$offset]);
  }

  public function offsetGet($offset) {
    return @$this->_data[$name];
  }

  public function offsetSet($offset, $value) {
    $this->_data[$offset] = $value;
  }

  public function offsetUnset($offset) {
    unset($this->_data[$offset]);
  }

  public function identity() {
    return $this->id;
  }

  public function saved() {
    return false;
  }

}
